local gamelib = require "club.threecard.gamelib"

local M = gamelib.ui.element()

M.clips = 
{
    big_win = {clip = "big_win_clip", time = 0.5}
    mega_win = {clip = "mega_win_clip", time = 1.5}
    blaze_win = {clip = "blaze_win_clip", time = 2.5}
}

function M:ctor(res)
    self.res = "club.threecard.slotlib/fx/common.b:blaze_win"
    self.current_clip = nil
    self.value = 0
end

function M:play(value, clip, parent)
    self.current_clip = clip
    self.value = value
    self.parent = parent
    self:lazy("on_play")
    return self.current_clip.time
end

function M:close()
    if not self.loaded then
        return
    end

    self.animator:Play("exit_win_clip")
end

function M:on_play()
    self.transform:SetParent(self.parent, false)
    self:show()
    self.animator:Play(self.current_clip.clip)
    gamelib.utility.digit(self.value_txt, 0, self.value, nil, self.current_clip.time)

    self.current_clip = nil
end

return M